<template>
  <div>
    <div class="two address">
      <div>
        <span class="title">客户内网分流URL地址</span>
        <el-button type="primary" size="small" @click="addUrl">添加一行</el-button>
      </div>
      <el-form ref="URLData" :model="{URLData}">
        <el-table
          :header-cell-style="{'text-align':'center'}"
          :cell-style="{'text-align':'center'}"
          :data="URLData"
          border
          stripe
        >
          <el-table-column type="index" label="序号" width="80" />
          <el-table-column label="URL" width="440" prop="CUSTOMER_URL">
            <template slot-scope="scope">
              <el-form-item
                :prop="'URLData.'+scope.$index+'.CUSTOMER_URL'"
                :rules="[
                  { required: true, message: 'bitian', trigger: 'blur' },
                  { pattern: /^[a-z0-9_-]{6,18}$/, message: '格式错误', trigger: 'blur' }
                ]"
              >
                <el-input v-model="scope.row.CUSTOMER_URL" size="mini" placeholder="请输入内容"></el-input>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <div>
                <el-button size="small" type="danger" @click="delUrl(scope.$index)">删除</el-button>
              </div>
            </template>
          </el-table-column>

        </el-table>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      URLData: [
        { id: 1, CUSTOMER_URL: '' },
        { id: 2, CUSTOMER_URL: '' },
        { id: 3, CUSTOMER_URL: '' }
      ],
      rules: {
        CUSTOMER_URL: [
          { required: true, message: 'bitian', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    addUrl () {
      console.log(123)
      this.URLData.push({ id: new Date(), CUSTOMER_URL: '' })
    },
    delUrl(index) {
      console.log(index)
      // this.URLData = this.URLData.filter(i => i.id !== id)
      this.URLData.splice(index, 1)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
